home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / Mops 2.7 / Mops source / More classes / dateTime < prev    next >
Text File  |  1995-09-02  |  1KB  |  76 lines

  1. \ Date - Date/time support
  2. \ 01/15/85   cbd  Version 1
  3. \ 03/11/87   rfl  ability to put any date in and print it
  4. \                  also changed basicstr to bytes
  5. \ July 90    mrh  Mops version.  Gives choice as to day and month order.
  6.  
  7. decimal
  8.  
  9. true    value    DMY?        \ Set true for day/month/year order (Aussie)
  10.  
  11. scon    DAYNAMES    "SunMonTueWedThuFriSat"
  12.  
  13. :code SECS2DATE        \ ( secs dtRec -- )
  14.     pop    a0
  15.     pop    d0
  16.     call    Secs2Date
  17. ;code
  18.  
  19. :code GETDATETIME        \ Apparently Apple don't want us to just
  20.                         \ do  $ 20C @  any more.
  21.     clr.l    -(a6)
  22.     move.l    a6,a0
  23.     exg    a6,a7
  24.     call    ReadDateTime
  25.     exg    a6,a7
  26.     rts
  27. ;code
  28.  
  29.  : DIG2        0 <# # # #>  type  ; 
  30.  
  31.  
  32. :class    DATETIME    super{ object }
  33. record{
  34.     int    Year
  35.     int    Month
  36.     int    Day
  37.     int    Hour
  38.     int    Minute
  39.     int    Second
  40.     int    dayOfWeek
  41. }
  42.  
  43. :m GET:    \ Gets the system date and time
  44.     getDateTime  ^base  secs2date  ;m
  45.  
  46. :m PUT:    ^base  secs2date  ;m
  47.  
  48. :m PRINTDAY:
  49.     get: dayOfWeek 1- 3 *  dayNames drop  +  3 type  ;m
  50.  
  51. :m PRINTDATE:
  52.     get: day  get: month
  53.     DMY? IF  swap  THEN
  54.     dig2  & /  emit   dig2  & /  emit
  55.     get: year 1900 - dig2  ;m
  56.  
  57. :m PRINTTIME:
  58.     get: hour  dig2  & : emit 
  59.     get: minute dig2  & : emit  get: second dig2  ;m
  60.   
  61. :m PRINT:
  62.     printday: self space   printdate: self   
  63.     2 spaces printtime: self  ;m
  64.  
  65. ;class
  66.  
  67. dateTime  sysDate
  68.  
  69. endload
  70.  
  71. \ To run this, try e.g.:
  72.  
  73. get: sysDate
  74. print: sysdate
  75.  
  76.